<template>
	<view class="collection">
		<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
			<swiper-item>
				<view class="swiper-item">
					<image src="@/static/31.jpg" mode=""></image>
				</view>
			</swiper-item>
			<swiper-item>
				<view class="swiper-item">
					<image src="@/static/32.jpg" mode=""></image>
				</view>
			</swiper-item>
		</swiper>
		<view class="box">
			<view class="title">热门游戏</view>
			<view class="content">
				<view class="game" v-for="item in list1" @click=drawFinished(item)>
					<image :src="item.img" mode=""></image>
					<view class="gameTitle">{{item.title}}</view>
				</view>
			</view>
		</view>
		<view class="box">
			<view class="title">模拟策略</view>
			<view class="content">
				<view class="game" v-for="item in list2" @click=drawFinished(item)>
					<image :src="item.img" mode=""></image>
					<view class="gameTitle">{{item.title}}</view>
				</view>
			</view>
		</view>
		<!-- <button @click="drawFinished">欢乐斗地主</button> -->
		<!-- <luckydraw class="luckydraw" @finish="drawFinished"></luckydraw> -->
	</view>
</template>
<script>
	import luckydraw from '../components/luckydraw/index.vue';
	export default {
		components: {
			luckydraw: luckydraw,
		},
		data() {
			return {
				list1: [{
						img: require('@/static/5.jpg'),
						title: '欢乐麻将',
						appId: 'wx375c80123d32f83f'
					},
					{
						img: require('@/static/1.jpg'),
						title: '欢乐斗地主',
						appId: 'wxd0e404d795ea6f80'
					},
					{
						img: require('@/static/2.jpg'),
						title: '欢乐五子棋',
						appId: 'wxbf60ee20e71490a2'
					},
					{
						img: require('@/static/3.jpg'),
						title: '羊了个羊',
						appId: 'wx141bfb9b73c970a9'
					},
					{
						img: require('@/static/4.jpg'),
						title: '天天象棋',
						appId: 'wx9e44d62c7ab75740'
					},
					{
						img: require('@/static/6.jpg'),
						title: '你画我猜',
						appId: 'wxa3b799f0dca49df4'
					}
				],
				list2: [{
						img: require('@/static/11.jpg'),
						title: '狼人杀',
						appId: 'wxc7143ceb7c11620e'
					},
					{
						img: require('@/static/12.jpg'),
						title: '谁是卧底',
						appId: 'wx344c62082c672780'
					},
					{
						img: require('@/static/13.jpg'),
						title: '超市模拟器',
						appId: 'wx02cd2c73dcd79497'
					},
					{
						img: require('@/static/14.jpg'),
						title: '开心消消乐',
						appId: 'wx29e1c40a97579c18'
					}
				],
			}
		},
		onShow() {},

		methods: {
			//接收转盘结束事件
			drawFinished(item) {
				wx.navigateToMiniProgram({
					appId: item.appId,
					path: '',
					envVersion: 'release',
					success(res) {
						// 打开成功
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.swiper-item {
		image {
			width: 700rpx;
			height: 300rpx;
		}
	}

	.collection {
		width: 100%;
		height: 100%;
		padding: 20rpx 30rpx;

		.box {
			.title {
				font-size: 40rpx;
			}

			.content {
				display: flex;
				align-items: center;
				flex-wrap: wrap;
				margin-top: 30rpx;

				.game {
					width: calc(50% - 30rpx);
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
					padding-bottom: 30rpx;

					image {
						width: 330rpx;
						height: 270rpx;
						border-radius: 20rpx;
					}

					.gameTitle {
						font-size: 35rpx;
					}
				}
			}
		}
	}
</style>
